package com.jianggy.druid;

import com.alibaba.druid.filter.config.ConfigTools;

/**
 *druid密码的加解密
 *@author jianggy
 *@date 2022/5/5
 *@version 1.0
 **/
public class DruidEncryptPassword {
    public static void main(String[] args) throws Exception {
        String password = "insightone123456";
        String[] keyPair = ConfigTools.genKeyPair(512);
        String privateKey = keyPair[0];
        String publicKey = keyPair[1];
        System.out.println("privateKey：" + privateKey);
        System.out.println("publicKey：" + publicKey);
        String encryptPassword = ConfigTools.encrypt(privateKey, password);
        System.out.println("加密后的密码：" + encryptPassword);
        String decryptPassword = ConfigTools.decrypt(publicKey, encryptPassword);
        System.out.println("公钥解密后的密码："+decryptPassword);
    }
}
